with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Enter_Protegit is
  Num_Voltes: Positive;

  protected Total is
    procedure Incrementa;
    function Get return Natural;
  private
    Tot: Natural := 0;
  end Total;

  protected body Total is
    procedure Incrementa is
    begin
      Tot := Tot + 1;
    end Incrementa;

    function Get return Natural is
    begin
      return Tot;
    end Get;
  end Total;

begin
  Put("Entra el nombre de voltes: ");
  Get(Num_Voltes);
  declare
    task T1;
    task T2;

    task body T1 is
    begin
      for i in 1..Num_Voltes loop
        Total.Incrementa;
--        Put('1');
      end loop;
    end T1;

    task body T2 is
    begin
      for i in 1..Num_Voltes loop
        Total.Incrementa;
--        Put('2');
      end loop;
    end T2;
  begin
    null;
  end;
  New_Line;
  Put("Total teoric: "); Put(2 * Num_Voltes); New_Line;
  Put("Total real:   "); Put(Total.Get); New_Line;
end Enter_Protegit;
